package com.rules.admin.unit;


import com.google.common.collect.Lists;
import com.rules.admin.unit.expect.Expect;
import com.rules.admin.unit.mock.Mock;

import java.util.List;

public class UnitCaseBuilder {
   private UnitCase unitCase = new UnitCase();

   public static UnitCaseBuilder newBuilder() {
      return new UnitCaseBuilder();
   }

   public UnitCaseBuilder artifactId(String artifactId) {
      this.unitCase.setArtifactId(artifactId);
      return this;
   }

   public UnitCaseBuilder groupId(String groupId) {
      this.unitCase.setGroupId(groupId);
      return this;
   }

   public UnitCaseBuilder addParams(Object value) {
      if (this.unitCase.getInParameters() == null) {
         this.unitCase.getInParameters().add(value);
      }

      this.unitCase.getInParameters().add(value);
      return this;
   }

   public UnitCaseBuilder unitCaseName(String name) {
      this.unitCase.setUnitCaseName(name);
      return this;
   }

   public UnitCaseBuilder addExpect(Expect expect) {
      if (this.unitCase.getExpects() == null) {
         List<Expect> expects = Lists.newArrayList();
         this.unitCase.setExpects(expects);
      }

      this.unitCase.getExpects().add(expect);
      return this;
   }

   public UnitCaseBuilder addMock(Mock mock) {
      if (this.unitCase.getMocks() == null) {
         List<Mock> mocks = Lists.newArrayList();
         this.unitCase.setMocks(mocks);
      }

      this.unitCase.getMocks().add(mock);
      return this;
   }

   public UnitCase build() {
      return this.unitCase;
   }
}
